<?php
function getIgnoreFolders($other=''){
	return array('.svn', 'CVS', "_thumbnails",$other);
}
function fileFilter($file_types = "jpg|jpeg|gif|bmp|png"){
    return "\.(" . strtolower($file_types) . "|" . strtoupper($file_types) . ")$";
}
function showListFolders($dir_path,$other=''){
	global $mainframe;
	//JFolder::create($fdProduct);
	//$dir_path = "../images/stories/galleries/";
	$folders  = JFolder::folders($dir_path, ".", false, false,getIgnoreFolders($other));
	return $folders;
}
function showListFiles($dir_path){
	 global $mainframe;
	 $filter   = fileFilter( "jpg|jpeg|gif|bmp|png" );
	 $files    = JFolder::files($dir_path, $filter, false, false, getIgnoreFolders());
	 return $files; 
}
function getMoreFolder($id){
	$db	=& JFactory::getDBO();
	
	$query = 'SELECT * FROM #__gallaries WHERE id!='.$id." ORDER BY RAND() LIMIT 0,20";
	$db->setQuery( $query );
	$rows = $db->loadObjectList();
	return $rows;	
}
function getFolderNameFromJoomfish($id,$lan_id){
	$db	=& JFactory::getDBO();
	
	$query = 'SELECT value FROM #__jf_content '.
			 ' WHERE reference_id='. $id .
			 ' AND language_id='. $lan_id .
			 ' AND published=1 '.
			 ' AND reference_table="gallaries" '.
			 ' AND reference_field="folder_name" ';
	$db->setQuery( $query );
	$rows = $db->loadResult();
	return $rows;
}
function getFolderName($id){
	$db	=& JFactory::getDBO();
	
	$query = 'SELECT folder_name FROM #__gallaries WHERE id='.$id;
	$db->setQuery( $query );
	$rows = $db->loadResult();
	return $rows;
}